import java.util.Arrays;

public class myStack {
    //用数组实现栈
    public int[] elem;
    public int usedSize;
    public myStack(){
        this.elem=new int[10];
    }
    //入栈
    public void push(int val){
        //分配内存空间
        if(isFull()){
            this.elem= Arrays.copyOf(elem,2*elem.length);
        }
        elem[usedSize++]=val;
    }
    //出栈
    public int pop(){
        if(empty()){
            return -1;
        }
        int val=elem[usedSize-1];
        usedSize--;
        return val;
    }
    //获取栈顶元素
    public int peek(){
        if(empty()){
            return -1;
        }
        int val=elem[usedSize-1];
        return val;
    }
    //判满
    public boolean isFull(){
        return elem.length==usedSize;
    }
    //判空
    public boolean empty(){
        return usedSize==0;
    }

}
